<template>
	<view style="background-color: white;">
		<u-navbar title="资讯详情" :autoBack="true" :bgColor="theme_color" :titleStyle="{color:'#ffffff'}"
			leftIconColor="#ffffff"></u-navbar>
		<view  :style="'margin-top:' + navH + 'px;'">
			<view style="padding:16px 20px;font-weight: 600;font-size: 24px;text-align: center;" v-if="from == 'news'">{{info.title || ''}}</view>
			<view style="padding: 10px;display: flex;color: #999696;justify-content: space-between;" v-if="from == 'news'">
				<view>作者:{{info.author || 'Admin'}}</view>
				<view>更新时间:{{info.update_time || ''}}</view>
				<view>{{info.views || ''}}浏览</view>
			</view>
			<view style="padding: 10px;text-align: center;color: #999696;" v-if="from == 'news'">
				{{info.remark || ''}}
			</view>
			<view style="padding: 10px;letter-spacing: 1px;line-height: 30px;width: 100vw;" v-if="from == 'news'">
				<view v-html="info.content"></view>
			</view>
			<view style="padding: 10px;letter-spacing: 1px;line-height: 30px;width: 100vw;height: 100vh;" v-if="from == 'store'">
				<view v-html="info"></view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		article_info
	} from '@/api/infomarket.js'
	import {
		store_article_info
	} from '@/api/store.js'
	export default {
		components: {},
		data() {
			return {
				navH: '',
				theme_color: getApp().globalData.theme_color,
				article_id:'',
				info:null,
				from:''
			}
		},
		onLoad(event) {
			console.log(event)
			this.article_id = event.article_id;
			this.navH = getApp().globalData.navHeight / 2;
			if(event.from == 'store'){
				this.from = 'store';
				store_article_info({
					article_id:this.article_id
				}).then(res=>{
					this.info = res.data;
				})
			}else{
				this.from = 'news';
				this.getDetail();
			}
		},
		//#ifdef MP
		// 分享到微信好友
		onShareAppMessage(e) {
			var imageUrl ='';
			if(this.info.pic_url != '' && this.info.pic_url){
				imageUrl = this.info.pic_url;
			}
			return {
				title: this.info.title,
				imageUrl: imageUrl,
				path: '/pages/news/detail?article_id='+ this.article_id
			};
		},
		//分享到朋友圈
		onShareTimeline(res) {
			var imageUrl ='';
			if(this.info.pic_url != '' && this.info.pic_url){
				imageUrl = this.info.pic_url;
			}
			return {
				title: this.info.title,
				imageUrl: imageUrl,
				path: '/pages/news/detail?article_id='+ this.article_id
			};
		},
		//#endif
		methods: {
			getDetail() {
				var that = this;
				article_info({
					id:that.article_id
				}).then(res=>{
					this.info = res.data;
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	page{
		background-color: white!important;
	}
	
</style>
